package edu.tyut.game

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import edu.tyut.game.databinding.ActivityMainBinding
import edu.tyut.game.utils.StatusBarUtils

class MainActivity : AppCompatActivity() {

    private val tag = this::class.java.name

    private lateinit var binding: ActivityMainBinding


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        // 隐藏ActionBar
        // 状态栏透明
        StatusBarUtils.setTranslucentStatusBar(this)

        val navView: BottomNavigationView = binding.navView

        // val navController = findNavController(R.id.nav_host_fragment_activity_main)
        // 这什么奇怪的错误，真纳闷了，StackOverflow神了
        val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment_activity_main) as NavHostFragment
        val navController = navHostFragment.navController
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations. 至多五个
        val appBarConfiguration = AppBarConfiguration(
            setOf(
                R.id.navigation_game,
                R.id.navigation_learn,
                R.id.navigation_community,
                R.id.navigation_person_center
            )
        )
        setupActionBarWithNavController(navController, appBarConfiguration)
        navView.setupWithNavController(navController)
    }

    companion object{
        fun actionStart(context: Context){
            val intent = Intent(context, MainActivity::class.java)
            context.startActivity(intent)
        }
    }
}
// px = dp * (dpi / 160)
// 小二哈
// package:edu.tyut.game -tag:EGL_emulation -tag:ProfileInstaller message:评论